<% @title = t("dashboards.show.my_subscriptions") %>

<% content_for :subject do %>
  <% render "dashboards/subject", user: current_user, current: :subscriptions %>
<% end %>

<h1 class="text-h2 mb-10 space-x-2">
  <span><%= t("dashboards.show.my_subscriptions") %></span>
  <% unless @subscribed_gems.size.zero? %>
    <span class="font-light text-neutral-600"><%= @subscribed_gems.size %></span>
  <% end %>
</h1>

<%= render CardComponent.new do |c| %>
  <% if @subscribed_gems.empty? %>
    <%= prose do %>
      <i><%= t("dashboards.show.no_subscriptions_html", :gem_link => link_to(t('dashboards.show.gem_link_text'), rubygem_path("rake"))) %></i>
    <% end %>
  <% else %>
    <%= c.list do %>
      <% @subscribed_gems.each do |gem| %>
        <%= c.list_item do %>
          <div class="flex flex-row w-full items-center justify-between">
            <%= link_to rubygem_path(gem.slug) do %>
              <h3 class="text-b1"><%= gem.name %></h3>
              <p class="text-b3"><%= short_info(gem.most_recent_version) %></p>
            <% end %>
            <%= button_to(
              rubygem_subscription_path(gem.slug),
              method: :delete,
              title: t("rubygems.aside.links.unsubscribe"),
              class: "h-8 w-8 ml-6 items-center justify-center outline-none -mr-2",
              aria: { label: t("rubygems.aside.links.unsubscribe") }
            ) do %>
              <%= icon_tag "close", class: "w-6 h-6" %>
            <% end %>
          </div>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
<% end %>
